package com.fanxuankai.boot.upload.dao;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fanxuankai.boot.upload.domain.ReadItem;

/**
 * @author fanxuankai
 */
public interface ReadItemDao extends IService<ReadItem> {
    /**
     * 任务读取的项目数
     *
     * @param jobId 任务
     * @return /
     */
    default int count(long jobId) {
        return count(Wrappers.lambdaQuery(ReadItem.class).eq(ReadItem::getJobId, jobId));
    }

    /**
     * 处理失败
     *
     * @param id      主键
     * @param message 错误信息
     */
    default void processFailed(long id, String message) {
        ReadItem entity = new ReadItem();
        entity.setId(id);
        entity.setMessage(message);
        updateById(entity);
    }
}
